const app = getApp();
import grace from "../../../utils/grace.js";

grace.page({
    /**
     * 页面的初始数据
     */
    data: {
      student_id: 0,
      student_name: '',
      state: ''
    },
    onLoad(e) {
        let that = this;
        that.$data = {
          'student_id': e.student_id,
          'student_name': e.student_name,
          'state': e.insure_state
        }
    },
    insure_submit(){
      let that = this;

      wx.showLoading({
          title: '加载中...',
      })
      // 保险报备
      let url = app.globalData.api + '/api/v1.0/insure/toApproval/' + that.$data.student_id + '/' + wx.getStorageSync('partner_id');
      let params = {
        token: wx.getStorageSync('token')
      }
      that.$http.put(url, params).then((res) => {
        if (res.data.code == 0) {
          // 报备成功
          console.log('发布成功');
          that.$goBack();
        } else {
          wx.showModal({
            title: '错误',
            content: res.data.msg,
            showCancel: false
          })
        }
        wx.hideLoading();
      }).catch(err => {
        console.log(err.status, err.message);
      })
    }
})